package signalprocessing;

import ikelib.drawTools;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

/**
 * 
 */

/**
 * @author ikechan
 *
 */
public class PlotAxisXView extends PlotAxis {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final int ScaleWidth    = 10;
	
	public String title1 = null;
	public String title2 = null;
	public String title3 = null;
	
	
	
	public PlotAxisXView(){
		setDirection(true);
		setAxisDivide(10,true,4,false);
		NumberFormat = new String("%.1f");
	}
	@Override
	public void paintComponent(Graphics g){
		 //super.paintComponent(g);   
		Dimension dm = this.getSize();

		Graphics2D g2 = (Graphics2D)g;
		
		if(Col!=null){
			g2.setBackground(Col.ColorBackGround);
			g2.setColor(Col.ColorAxis);
		}
		g2.clearRect(0,0,dm.width,dm.height);

	
		Rectangle northrect = new Rectangle(0,0,dm.width, ScaleWidth  );
		
		double ymax = getXScaleMax();
		double ymin = getXScaleMin();
		double span = ymax - ymin;
		int tick = getAxisDivide();
		String[] sl = new String[tick+1];
		for(int i=0;i<tick+1;i++){
			double label = ymin + i* span/(tick);
			sl[i] =  new String(String.format(NumberFormat,label));
			
		}
		drawAxis(g2,AxisPlacedBottom,northrect,tick,sl);
		if(TitleDisplay){
			Font f = g2.getFont();
			Font f2 = f.deriveFont(Font.BOLD);
			g2.setFont(f2);
			drawTools.drawText(g2, Title, dm.width/2, dm.height, drawTools.POSITION_CENTER_BOTTOM);
			g2.setFont(f);
		}
		

//		if(title1 !=null) drawTools.drawText(g2,title1,2,dm.height/2,drawTools.POSITION_CENTER_TOP,Math.PI*3.0/2.0);
//		if(title2 !=null) drawTools.drawText(g2,title2,15,dm.height/2,drawTools.POSITION_CENTER_TOP,Math.PI*3.0/2.0);
//		if(title3 !=null) drawTools.drawText(g2,title3,2,20*3,drawTools.POSITION_LEFT_TOP);
		
	}
	
}
